using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Midas.Core
{
	public class MidasFileListener: IDisposable
	{
		private StreamWriter fileWriter;
		public void LogEvent(string s)
		{
			fileWriter.WriteLine(string.Format("{0}: {1}", DateTime.Now.ToString("s"), s));
			fileWriter.Flush();
		}

		public MidasFileListener(string filename)
		{
			fileWriter = new StreamWriter(filename);
		}
		private MidasFileListener() { }

		#region IDisposable Members

		void IDisposable.Dispose()
		{
			if(fileWriter!=null)
				fileWriter.Close();
		}

		#endregion

		~MidasFileListener()
		{
			((IDisposable)this).Dispose();
		}
	}
}